<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${gameName }</title>
<link rel="stylesheet" type="text/css" href="js/showGameChatpost.css">
<link rel="stylesheet" type="text/css"
	href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="js/layui.css">
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
<script type="text/javascript"
	src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<!-- <script type="text/javascript" src="js/form.js"></script> -->
<script type="text/javascript" src="js/vue/vue.js"></script>
<script type="text/javascript">
	
</script>
</head>
<body>
     <script type="text/javascript">
     
     $(function() {

 		//判断该用户是否关注该游戏
 		//=======================================
 		var gameId ="${gameId}";
 			/* alert(gameId+" "+uid);  */
 		$.ajax({
 			url : 'testLoveOrNot.do',
 			type : 'post', 
 			data : {
 				gameId : gameId,
/*  				uid : uid */
 			},
 			dataType : 'json',
 			success : function(result) {
 				/* alert(result); */
 				vue.re = result;
 			}
 		})
 		//=========================================	
 		var vue = new Vue({
 			el : '#tt123',
 			data : {
 				re : "",
 			}
 		})

 	})
 	function hh() {
 		alert("123");
 	}
     
     </script>
	<%-- <%
		session.setAttribute("uid", 4);
	%> --%>
	<div id="body02">
		<nav class="navbar navbar-inverse" role="navigation"> ... </nav>
		<div id="tt123">
			<table width="100%">
				<tr>
					<td style="width: 33%"><a href="html/ChatIndex.jsp" id="return01">返回讨论区首页</a></td>
					<td><span style="font-size: 16px; width: 34%">${gameName }</span>
					<c:if test="${sessionScope.user.uid !=null }">
						<template v-if="re==true">
						<button class="layui-btn layui-btn-normal layui-btn-sm"
							value="${gameId }" id="love">
							<i class="layui-icon">+关注</i>
						</button>
						</template> <template v-if="re==false">
						<button class="layui-btn layui-btn-normal layui-btn-sm">
							<i class="layui-icon">√</i>
						</button>
						<button  class="layui-btn layui-btn-normal layui-btn-sm" value="${gameId }" id="hite">
						   <i class="layui-icon">取消关注</i>
						</button>
						</template>
						</c:if>
						</td>
					<td style="width: 33%">
					<c:if test="${sessionScope.user.uname !=null}"><a href="#">${sessionScope.user.uname }</a>欢迎你</c:if>
					<c:if test="${sessionScope.user.uname ==null}"><a href="#">登陆</a></c:if>
					</td>
				</tr>
			</table>
		</div>
		<div id="di01">
			<c:forEach items="${gameChatList }" var="li">
				<div class="list-group">
					<div class="list-group-item" style="height: 100px;">
						<h4 class="list-group-item-heading">
							<a
								href="chatContent?postId=${li.postId }&postTitle=${li.postTitle}&postContent=${li.postContent}&gameName=${gameName}&gameId=${gameId}&uname=${li.user.uname}&photo=${li.user.photo}&postPicture=${li.postPicture}">${li.postTitle }</a>
						</h4>
						<p class="list-group-item-text"
							style="height: 45px; overflow: hidden; text-overflow: ellipsis; line-height: 22px">${li.postContent }</p>
						<span>昵称：${li.user.uname }</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span>发帖时间：${li.postTime }</span>
					</div>
				</div>
			</c:forEach>
			<ul class="pagination">
				<li><a href="showGameChat?gid=${gameId }&currentPage=1">首页</a></li>

				<c:if test="${curr != 1}">
					<li><a
						href="showGameChat?gid=${gameId }&currentPage=${curr-1}">&laquo;</a></li>
				</c:if>
				<%-- <li><a href="showGameChat?gid=${gameid }&currentPage=1">1</a></li>
  <li><a href="showGameChat?gid=${gameid }&currentPage=2">2</a></li>
  <li><a href="showGameChat?gid=${gameid }&currentPage=3">3</a></li>
  <li><a href="showGameChat?gid=${gameid }&currentPage=4">4</a></li>
  <li><a href="showGameChat?gid=${gameid }&currentPage=5">5</a></li> --%>
				<c:if test="${curr !=pages }">
					<li><a
						href="showGameChat?gid=${gameId }&currentPage=${curr+1}">&raquo;</a></li>
				</c:if>
				<li><a href="showGameChat?gid=${gameId }&currentPage=${pages}">末页</a></li>
			</ul>
		</div>
		<form action="addChatPost.do" style="margin-left: -100px;" method="post"
			enctype="multipart/form-data">
			<div class="layui-form-item">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<input type="hidden" value="${gameId }" name="gameId"> <input
						type="hidden" value="3" name="uid">
					<!-- 设置发帖人的Id -->
					<input type="hidden" value="${gameName }" name="gameName">
					<input type="hidden" value="${curr }" name="currentPage"> <input
						type="text" name="title" lay-verify="title" autocomplete="off"
						placeholder="请输入标题" class="layui-input">
				</div>
			</div>

			<div class="layui-form-item layui-form-text"
				style="margin-top: -10px">
				<label class="layui-form-label"></label>
				<div class="layui-input-block">
					<textarea placeholder="请输入内容" class="layui-textarea"
						name="postContent"></textarea>
				</div>
			</div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="file" name="image" class="layui-input"> <input
						class="layui-btn" type="submit" lay-filter="demo1" value="发表">
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>

	</div>

	<script type="text/javascript">

		$(function() {
			$("#tt123").delegate("button#love","click",function() {
				var gameId = $(this).val();
				$.ajax({
					url : 'userAddLoveGame.do',
					type : 'post',
					data : {
						gameId : gameId,
						/* uid : uid */
					},

				})
				window.location.reload();
			});

			$("#tt123").delegate("button#hite","click",function(){
				var gameId=$(this).val();
				/* alert(gameId+"  "+uid); */
				$.ajax({
					url:'userDeleteLoveGame.do',
					type:'post',
					data:{gameId:gameId},
				})
				window.location.reload();
			})
		});
		
		
	</script>

</body>
</html>